#ifndef __SERVER_ENGINE_H__
#define __SERVER_ENGINE_H__
#include <stdint.h>
#include "../utility/ugx_palloc.h"
#include "../net/request.h"

typedef int (*finish_callback)(void* result, size_t result_len, void* user_ptr);


typedef struct 
{
	bool (*init)(int argc, char** argv);
	void (*uninit)();
	uint8_t*(*process_sync)(_pool_t* pool, 
				const void* data, 
				size_t data_len, 
				request_t* request, 
				size_t* output_len);
	void	(*process_async)(_pool_t* pool, 
				const void* data, 
				size_t data_len, 
				finish_callback callback, 
				void* user_ptr);
} engine_t;

#ifdef __cplusplus
	extern "C" {
#endif
		bool load_engine(const char *soname, int argc, char** argv);
		void unload_engine();
		uint8_t* process_sync(_pool_t* pool, 
				const void* data, 
				size_t data_len, 
				struct request_tag* request, 
				size_t* output_len);
		void process_async(_pool_t* pool, 
				void* data, 
				size_t data_len, 
				finish_callback callback,
				void* user_ptr);
#ifdef __cplusplus
	}
#endif

#endif
